from pymongo import MongoClient
# 默认主机和端口
# client = MongoClient()
# 显示指定
try:
    client = MongoClient("localhost", 27017)
    print("连接成功")
except Exception as e:
    print(f"连接失败，错误原因{e}")